{$CLEO .qa}
{$USE CLEO+}
{$USE Audio}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "VHSQA"

// By ArtemQa146

const
    video_man = 31@
    micro_man = 30@
    render_model_C = 29@
    render_model_M = 28@
    VHS = 27@
    Micro = 26@
    progress = 25@
    coords_x = 24@
    coords_y = 23@
    coords_z = 22@
    angle_1 = 21@
end

0087: coords_x = 0@ // (float)
0087: coords_y = 1@ // (float)
0087: coords_z = 2@ // (float)
0087: angle_1 = 3@ // (float)
0085: render_model_C = 4@ // (int)
0085: render_model_M = 5@ // (int)


if
    0E4D: random_percent 6@
then
else
    repeat
    wait 0
    until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos coords_x coords_y coords_z radius 150.0
    0A93: terminate_this_custom_script
end


        repeat
        wait 0
        04ED: load_animation  "PedEventsMod"
        until 04EE:   animation "PedEventsMod" loaded

        model.Load(48)
        model.Load(17)
        if
            not model.Available(48)
        then
            repeat
            wait 0
            model.Load(48)
            until model.Available(48)
        end
        if
            not model.Available(17)
        then
            repeat
            wait 0
            model.Load(17)
            until model.Available(17)
        end
        038B: load_requested_models

        009A: video_man = create_actor_pedtype 21 model 48 at coords_x coords_y coords_z
        0173: set_actor video_man Z_angle_to angle_1
        0E24: fix_char video_man ground 1 brightness 1 and_fade_in 0
        0812: AS_actor video_man perform_animation "video_c" IFP "PedEventsMod" framedelta 8.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB
        0F02: create_render_object_to_char_bone_from_special video_man special_model render_model_C bone 24 offset 0 0 0 rotation 0 0 0 store_to VHS

        04C4: store_coords_to 1@ 2@ 3@ from_actor video_man with_offset 0.0 2.0 0.0
        009A: micro_man = create_actor_pedtype 21 model 17 at 1@ 2@ 3@
        angle_1 += 180.0
        0173: set_actor micro_man Z_angle_to angle_1
        0E24: fix_char micro_man ground 1 brightness 1 and_fade_in 0
        0812: AS_actor micro_man perform_animation "video_m" IFP "PedEventsMod" framedelta 8.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB
        0F02: create_render_object_to_char_bone_from_special micro_man special_model render_model_M bone 24 offset 0 0 0 rotation 0 0 0 store_to Micro

        model.Destroy(48)
        model.Destroy(17)
        
        timera = 0
        
        wait 500

        repeat
        wait 0
        if and
            056D:   actor video_man defined
            056D:   actor micro_man defined
        then

            080E: get_actor video_man ped_event_to 1@
            if or
                0118:   actor video_man dead
                not locate_char_distance_to_char $player_actor char video_man radius 150.0
                not $ACTIVE_INTERIOR == 0
                051A:   actor video_man damaged_by_actor $PLAYER_ACTOR
                not is_char_script_controlled video_man
                1@ == 49
                1@ == 9
            then
                0E2F: delete_render_object VHS
                0E2F: delete_render_object Micro
                break
            end
            
            080E: get_actor micro_man ped_event_to 1@
            if or
                0118:   actor micro_man dead
                not locate_char_distance_to_char $player_actor char micro_man radius 150.0
                051A:   actor micro_man damaged_by_actor $PLAYER_ACTOR
                not is_char_script_controlled micro_man
                1@ == 49
                1@ == 9
            then
                0E2F: delete_render_object VHS
                0E2F: delete_render_object Micro
                break
            end
            
            080E: get_actor micro_man ped_event_to 1@
            080E: get_actor video_man ped_event_to 2@
            if or
                1@ == 15
                1@ == 31
                1@ == 59
                2@ == 15
                2@ == 31
                2@ == 59
            then
                0E2F: delete_render_object VHS
                0E2F: delete_render_object Micro
                break
            end
            
            if or
                0457:   player $PLAYER_CHAR aiming_at_actor micro_man
                0457:   player $PLAYER_CHAR aiming_at_actor video_man
            then
                0E83: get_current_char_weaponinfo $PLAYER_ACTOR store_to 1@
                0E89: get_weaponinfo_fire_type 1@ store_to 2@ //     
                if or
                    2@ == 1 //  
                    2@ == 3 //   (  ..)
                then
                    0E2F: delete_render_object VHS
                    0E2F: delete_render_object Micro
                    break
                end
            end
            
            04C4: store_coords_to 1@ 2@ 3@ from_actor micro_man with_offset 0.0 -2.5 0.0
            if
                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 2.0
            then
                if
                    timera > 10000
                then
                    0E2F: delete_render_object VHS
                    0E2F: delete_render_object Micro
                    01C2: remove_references_to_actor micro_man // Like turning an actor into a random pedestrian
                    if 056D:   actor micro_man defined
                    then 05E2: AS_actor micro_man kill_actor $PLAYER_ACTOR
                    end
                    01C2: remove_references_to_actor video_man // Like turning an actor into a random pedestrian
                    if 056D:   actor video_man defined
                    then 05E2: AS_actor video_man kill_actor $PLAYER_ACTOR
                    end
                    break
                end
            else
                timera = 0
            end
            
            if
                0EE4: locate_char_distance_to_char $PLAYER_ACTOR char video_man radius 20.0
            then
                if
                    timerb > 120000
                then
                    0E2F: delete_render_object VHS
                    0E2F: delete_render_object Micro
                    break
                end
            else
                timerb = 0
            end
            
            if or
                8611:   actor video_man performing_animation "video_c"
                8611:   actor micro_man performing_animation "video_m"
            then
                0E2F: delete_render_object VHS
                0E2F: delete_render_object Micro
                break
            end





        else
            break
        end

        until not player.Defined(0)

            if 056D:   actor video_man defined
            then 01C2: remove_references_to_actor video_man // Like turning an actor into a random pedestrian
            end
            if 056D:   actor micro_man defined
            then 01C2: remove_references_to_actor micro_man // Like turning an actor into a random pedestrian
            end
        04EF: release_animation "PedEventsMod"

        repeat
        wait 0
        until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos coords_x coords_y coords_z radius 100.0

        wait 60000

0A93: terminate_this_custom_script

